﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AutoTrader
{
    public partial class AutoTraderForm
    {
        private bool CancelOrders()
        {
            try
            {
                if (0 != BaseOrder.ID)//if 0 there is no order - create one but first get two steps to decide buy or sell
                {
                    obj.CancelOrder(BaseOrder.ID);
                    BaseOrder.ID = 0;
                }

                if (0 != StopOrder.ID)//if 0 there is no order - create one but first get two steps to decide buy or sell
                {
                    obj.CancelOrder(StopOrder.ID);
                    StopOrder.ID = 0;
                }

                WriteOrderSettings();
            }
            catch (Exception ex)
            {
                myLogger.Add(string.Format("CancelOrders : Runtime exception: {0}-{1}", ex.Message, ex.StackTrace));
                return false;
            }

            return true;
        }

    }
}
